package com.solution.delegate;

import java.util.List;

import com.solution.exception.DelegateException;
import com.solution.exception.ServiceBeanException;
import com.solution.exception.ServiceLocatorException;
import com.solution.model.Communication;
import com.solution.model.CommunicationType;
import com.solution.service.CommunicationService;
import com.solution.service.CommunicationTypeService;
import com.solution.util.SearchVO;
import com.solution.util.ServiceLocator;

public class CommunicationServiceDelegate implements CommunicationService, CommunicationTypeService{

	private CommunicationService communicationService;
	private CommunicationTypeService communicationTypeService;
	
	public CommunicationServiceDelegate() throws DelegateException{
		try {
			communicationService = (CommunicationService)ServiceLocator.getInstance().getRemoteService("CommunicationService");
			communicationTypeService = (CommunicationTypeService)ServiceLocator.getInstance().getRemoteService("CommunicationTypeService");
		}
		catch (ServiceLocatorException e) {
			throw new DelegateException(e); 
		}
	}
	
	public List<Communication> getCommunications(SearchVO searchVO)throws ServiceBeanException{
		return communicationService.getCommunications(searchVO);
	}
	public void sendSMS(String mobileNumber, String message, long clientId, String userName) throws ServiceBeanException{
		communicationService.sendSMS(mobileNumber, message, clientId, userName);
	}
	public void sendEmail(String email, String message, String subject, long clientId, String userName) throws ServiceBeanException{
		communicationService.sendEmail(email, message, subject, clientId, userName);
	}
	public CommunicationType fetchCommunicationTypeByName(String name) throws ServiceBeanException{
		return communicationTypeService.fetchCommunicationTypeByName(name);
	}
}
